package com.ykt.mall.ctrl;
import java.util.ArrayList;
import java.util.List;

import com.jfinal.ext.route.ControllerBind;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.ykt.interceptor.Seach;
import com.ykt.mall.pageModel.TreeNode;
import com.ykt.model.ProductType;
@ControllerBind(controllerKey="/productType")
public class ProductTypeCtrl extends AdminBaseCtrl<ProductType>{
	public ProductTypeCtrl() {
		super(ProductType.class);
	}
	public void combobox(){
		List<ProductType> list=ProductType.dao.find("select * from product_type order by seq");
		this.renderJson(list);
	}
				
	public void combotree() {
		List<Record> dataList =null;
		String sql="select id,name,pid from product_type where 1=1 ";
		
		
		Integer id=getParaToInt(0,0);
		if(id==0) dataList = Db.find(sql);
		else dataList = Db.find(sql+" and  shop_id = ?",id);
		
		
		
		
		List<TreeNode> list = new ArrayList<TreeNode>();
		TreeNode rootNode = new TreeNode();
		rootNode.setId(0);
		rootNode.setText("");
		rootNode.setIconCls("icon-home");
		rootNode.setCanChk(false);
		//rootNode.setChecked(true);
		fillTree(dataList, rootNode,"name",true,null);
		list.add(rootNode);
		this.renderJson_(list);
	}
}
